import { createRouter, createWebHistory } from "vue-router";
import HomeView from "../views/HomeView.vue";

// const routes = [
//   {
//     path: "/",
//     name: "home",
//     component: HomeView,
//   },
//   {
//     path: "/about",
//     name: "about",
//     // route level code-splitting
//     // this generates a separate chunk (about.[hash].js) for this route
//     // which is lazy-loaded when the route is visited.
//     component: function () {
//       return import(/* webpackChunkName: "about" */ "../views/AboutView.vue");
//     },
//   },
// ];
import IndexLayout from "../layouts/IndexLayout.vue";

const routes = [
  {
    path: "/",
    name: "home",
    component: IndexLayout,
    children: [
      {
        path: "/",
        component: () => import("../views/IndexView.vue"),
      },
      {
        path: "/news",
        component: () => import("../views/news/Index.vue"),
      },
      {
        path: "/news/:id",
        component: () => import("../views/news/Single.vue"),
      },
      {
        path: "/scope",
        component: () => import("../views/scope/Index.vue"),
      },
      {
        path: "/case",
        component: () => import("../views/case/Index.vue"),
      },
      {
        path: "/aboutUs",
        component: () => import("../views/aboutUs/Index.vue"),
        children: [
          {
            path: "",
            component: () => import("../views/aboutUs/Resume.vue"),
          },
          {
            path: "/aboutUs/resume",
            component: () => import("../views/aboutUs/Resume.vue"),
            meta: {
              keepAlive: true, //设置页面是否需要使用缓存
            },
          },
          {
            path: "/aboutUs/culture",
            component: () => import("../views/aboutUs/Culture.vue"),
            meta: {
              keepAlive: true, //设置页面是否需要使用缓存
            },
          },
          {
            path: "/aboutUs/team",
            component: () => import("../views/aboutUs/Team.vue"),
            meta: {
              keepAlive: true, //设置页面是否需要使用缓存
            },
          },
          {
            path: "/aboutUs/contact",
            component: () => import("../views/aboutUs/Contact.vue"),
            meta: {
              keepAlive: true, //设置页面是否需要使用缓存
            },
          },
          {
            path: "/aboutUs/join",
            component: () => import("../views/aboutUs/Join.vue"),
            meta: {
              keepAlive: true, //设置页面是否需要使用缓存
            },
          },
        ],
      },
    ],
  },
  {
    path: "/404",
    component: () => import("../views/error/404.vue"),
  },
  {
    path: "/:catchAll(.*)",
    redirect: "/404",
  },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

export default router;
